# coding: utf-8
import time
import frida
import sys

# 127.0.0.1:7555
device = frida.get_usb_device()
pid = device.spawn("com.shizhuang.duapp")
session = device.attach(pid)
# com.shizhuang.duapp.common.utils.RequestUtils
print(session)
# com.shizhuang.duapp.common.utils.RequestUtils
js = '''
Java.perform(function(){
var RequestUtilsCls = Java.use('com.shizhuang.duapp.common.utils.RequestUtils');

RequestUtilsCls.a.overload('java.util.Map', 'long').implementation = function(a,b){
        var rc = this.a(a,b);
        console.log("a= " + a.entrySet().toArray());
        console.log("b= " + b);

        console.log("a1 >>> rc= " + rc);

        return rc ;
}

RequestUtilsCls.b.overload('java.util.Map', 'long').implementation = function(a,b){
        var rc = this.b(a,b);
        console.log("a= " + a.entrySet().toArray());
        console.log("b= " + b);

        console.log("b1 >>> rc= " + rc);

        return rc ;
}

RequestUtilsCls.c.implementation = function(a,b){
        var rc = this.c(a,b);
        console.log("a= " + a.entrySet().toArray());
        console.log("b= " + b);

        console.log("c1 >>> rc= " + rc);

        return rc ;
}
}

)

'''


def on_message(message, data):
    print('222222222222222222', data)
    if message["type"] == "send":
        print("[+] {}".format(message["payload"]))
    else:
        print("[-] {}".format(message))


script = session.create_script(js)
script.on("message", on_message)
script.load()
